/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.fyx.cms.web;

import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import org.fyx.mula.controll.MulaLanguageFacadeLocal;
import org.fyx.mula.entity.MulaLanguage;

/**
 *
 * @author ydenek
 */
@ManagedBean
@RequestScoped
public class LanguageConverter implements Converter {

    @EJB
    private MulaLanguageFacadeLocal mulaLanguageFacade;

    @Override
    public Object getAsObject(FacesContext context, UIComponent component, String value) {
        return mulaLanguageFacade.find(value);
    }

    @Override
    public String getAsString(FacesContext context, UIComponent component, Object value) {
        return ((MulaLanguage) value).getIsoLanguage();
    }
}
